package
{
	import flash.geom.Matrix;
	import flash.geom.Matrix3D;
	import flash.geom.Point;
	import flash.geom.Vector3D;

	public class IsometricTransformer implements ITransformer
	{
		private var m_isoMatrix:Matrix3D;
		public static const PPC_X:Number = 50;
		public static const PPC_Y:Number = 25;
		public static const PPC_Z:Number = 10;
		public function IsometricTransformer()
		{
			var _cos:Number = Math.cos(45*Math.PI/180);
			var _sin:Number = Math.sin(45*Math.PI/180);
			
			m_isoMatrix = new Matrix3D();
			m_isoMatrix.appendRotation( -90, Vector3D.X_AXIS );			
			m_isoMatrix.appendRotation( -135, Vector3D.Y_AXIS );
			m_isoMatrix.appendRotation( 35.264, Vector3D.X_AXIS );			
			
			m_isoMatrix.appendScale(PPC_X,PPC_Y,PPC_Z);
			
			
		}
		
		public function transform(ipos:IRenderable):void{
			var pos:Vector3D = ipos.getPosition();
			var res:Vector3D = m_isoMatrix.transformVector(ipos.getPosition());

			ipos.setDisplayPosition(res.x, res.y);
		}
	}
}